home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6176 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  969 b 

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: newing char**
  5. Date: 11 Feb 1996 11:16:20 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4fkj64$mpl@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Feb 09, 1996 22:03:01 in article <newing char**>, 'jono@cse.ucsc.edu
  15. (Jonathan Gibbs)' wrote: 
  16.  
  17.  
  18. >If I have the following declaration: 
  19. >char **name; 
  20. >The following line compiles fine with g++, but I get the following  
  21. >error on SGI's CC. Which is right? 
  22. >int num;  
  23. >name = new (char*)[num]; 
  24.  ^^^^^^^^^^^^^^^^^^^^^ 
  25. Don't you get a compiler error here? 
  26. It should be:  name = new char*[num]; 
  27. >for (int i=0; i < num; i++) { 
  28. >name = new char[25]; 
  29. ^^^^^^^^^^^^^^^^^^^ 
  30. name[i] = new char[25]; 
  31.  
  32. >} 
  33.  
  34. -- 
  35. Pete Grant 
  36. Kalevi, Inc. 
  37. Object Oriented Software Development
  38.